#ifndef HANDLEINTERFACE_H
#define HANDLEINTERFACE_H

#include <QObject>
#include <src/Entity/clientdefect.h>
#include "src/Models/NormalDefectModels.h"

/************
 *
 * 责任链 用于json中设定的条件进行对比
 *
 * */


/**
 * @brief 请求接口
 **/
class Handle : public QObject
{
    Q_OBJECT
public:
    explicit Handle(QObject *parent = nullptr){}

public:

    //设置责任链
    virtual Handle *SetNext(Handle * handle) = 0;

    //传入的是请求，处理类
    virtual void  handle(NormalDetectBase &n,VerticalLengthDetectBase &v,FrequencyDetectBase &f,DirectLevelBase &d,BesideDetectBase &b,SteelInfo * steelinfo) = 0;
};



/**
 * @brief 请求基类
 */
class HandleBase : public Handle{
    Q_OBJECT
public:
    HandleBase()
        :nextHandle(nullptr){
    }

signals:
    void DetectFinish(SteelInfo * steel);
protected:
    Handle * nextHandle;

    // Handle interface
public:
    Handle *SetNext(Handle *handle){
        this->nextHandle = handle;
        return this->nextHandle;
    }

    // Handle interface
public:
     void handle(NormalDetectBase &n, VerticalLengthDetectBase &v, FrequencyDetectBase &f, DirectLevelBase &d, BesideDetectBase &b, SteelInfo *steelinfo){
         if(this->nextHandle){
             this->nextHandle->handle(n,v,f,d,b,steelinfo);
         }
    };
};


//判级一级处理类
class DefectOneHandle : public HandleBase{
    Q_OBJECT

    // Handle interface
public:
    void handle(NormalDetectBase &n, VerticalLengthDetectBase &v, FrequencyDetectBase &f, DirectLevelBase &d, BesideDetectBase &b, SteelInfo *steelinfo);
};



//判级二级处理类
class DefectTwoHandle : public HandleBase{
    Q_OBJECT

    // Handle interface
public:
    void handle(NormalDetectBase &n, VerticalLengthDetectBase &v, FrequencyDetectBase &f, DirectLevelBase &d, BesideDetectBase &b, SteelInfo *steelinfo);
};



//判级三级处理类
class DefectThreeHandle : public HandleBase{
    Q_OBJECT

    // Handle interface
public:
    void handle(NormalDetectBase &n, VerticalLengthDetectBase &v, FrequencyDetectBase &f, DirectLevelBase &d, BesideDetectBase &b, SteelInfo *steelinfo);
};

#endif // HANDLEINTERFACE_H
